<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>资金管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">资金类型</label>
            <div class="layui-input-inline">
              <select name="fundType" lay-filter="aihao">
                <option value="1">余额</option>
                <option value="3">贡献值</option>
                <option value="4">共享值</option>
              </select>
            </div>
          </div>          
          <div class="layui-inline">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-inline">
              <input name="timestr" id="laydate-cn" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">流水号</label>
            <div class="layui-input-inline">
              <input type="text" name="payCode" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div> 
          <div class="layui-inline">
            <label class="layui-form-label">支出|收入</label>
            <div class="layui-input-inline">
				<select name="isout" class="select">
					<option value="">全部</option>
					<option value="1">收入</option>
					<option value="0">支出</option>
				</select>
			</div>
          </div>                              
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
          </div>
        </div>
      </div>

      <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
          <button class="layui-btn layuiadmin-btn-list" data-type="add">共享值转余额</button>
        </div>
        <table class="layui-table" lay-filter="table" id="table">
        <script type="text/html" id="isout">
                        {{#  if(d.isout == 1){ }}
                        <button class="layui-btn layui-btn-xs">收入</button>
                        {{#  } else { }}
                        <button class="layui-btn layui-btn-primary layui-btn-xs">支出</button>
                        {{#  } }}
        </script>
        <script type="text/html" id="table-operate">
          <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
        </script>
      </div>
    </div>
  </div>


<script src="/layuiadmin/layui/layui.js" charset="utf-8"></script>
<script>

    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','laydate', 'table'], function(){
        var $ = layui.$,form = layui.form,
            element = layui.element,laydate=layui.laydate, table = layui.table;

        form.render('select');
        laydate.render({
            elem: '#laydate-cn',
            range:'~'
        });
        table.render({
            elem : '#table',
            url:'/account/queryAccountDetail',
            page:true,
            request: {
                pageName: 'current', //页码的参数名称，默认：page
                limitName: 'size' //每页数据量的参数名，默认：limit
            }
            ,cols: [[
                {field:'id',title: '编号', minWidth:60,fixed:'center' }
                ,{field:'payCode', width:180, title: '流水号'}
                ,{field:'isout', width:90, title: '收/支',templet:"#isout"}
                ,{field:'cost', width:120, title: '金额'}
                ,{field:'last', width:120, title: '最后结余'}
                ,{field:'typeName', width:120, title: '类型'}
                ,{field:'createtime',title:'时间',minWidth:160,templet:"<div>{{d.createTime==''? '' :layui.util.toDateString(d.createTime,'yyyy-MM-dd HH:mm:ss')}}</div>"}
                ,{field:'remark',title: '描述', minWidth:120, fixed:'right'}
            ]]
        });

        form.on('submit(LAY-app-contlist-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('table', {
                where: field
            });
        });
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            //日期范围
            laydate.render({
                elem: '#laydate-cn'
                ,range: true
            });

        });
        
        var active = {
            add: function(){
                layer.open({
                  type: 2
                  ,title: '共享值转余额'
                  ,content: '/account/trans'
                  ,maxmin: true
                  ,area: ['550px', '300px']
                  ,btn: ['确定', '取消']
                  ,yes: function(index, layero){
                    //点击确认触发 iframe 内容中的按钮提交
                    var submit = layero.find('iframe').contents().find("#layuiadmin-app-form-submit");
                    submit.click();
                  }
                }); 
              }
        };
        
        $('.layui-btn.layuiadmin-btn-list').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
          });
    });


</script>
</body>
</html>